package Test;

import Dao.Implement.userDaoImplement;
import Dao.userDao;
import Service.Implement.userServiceImplement;
import Service.userService;
import org.junit.Test;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import returnDataStruct.messageList;
import returnDataStruct.pkValueData;
import returnDataStruct.roomListData;

import java.math.BigInteger;
import java.sql.Date;

import static org.junit.Assert.*;

public class useServiceImplementTest {

   public userService userServiceGet(){
       ApplicationContext applicationContext=new ClassPathXmlApplicationContext("bean1.xml");
       userService userService=(userService) applicationContext.getBean("userServiceImplement");
       return userService;
   }
   @Test
   public void loginIn(){
       userService userService=userServiceGet();
       System.out.println(userService.loginIn("10205101426","TestOne"));
   }


    @Test
    public void joinRoomTest(){
        userService userService=userServiceGet();
        System.out.println(userService.joinRoom(new Long("4"),"2",new Long("22")));
    }


    @Test
    public void createRoomTest(){
        userService userService=userServiceGet();
        System.out.println(userService.createRoom(new Long("2"),4,"2","2022-11-05","大学生活动中心羽毛球馆","排球场一号",9,10));
    }

    @Test
    public void queryInformationByIDTest(){
        userService userService=userServiceGet();
        System.out.println(userService.queryInformationByID(new Long("1")));
    }
    @Test
    public void deleteRoomBTest(){
        userService userService=userServiceGet();
        System.out.println(userService.deleteRoom(new Long("22")));

    }
    @Test
    public void exitRoomTest(){
        userService userService=userServiceGet();
        System.out.println(userService.exitRoom(new Long("22"),new Long("3")));
    }

    @Test
    public void queryUserById(){
       userService userService=userServiceGet();
        System.out.println(userService.queryUserByid(Long.parseLong("1")));
    }

    @Test
    public void queryUserOrder(){
       userService userService=userServiceGet();
        System.out.println(userService.queryUserByStudentId("10205101426"));
        System.out.println(userService.queryUserOrder(userService.queryUserByStudentId("10205101426").getUser_id()));
        roomListData result = new roomListData(userService.queryUserOrder(userService.queryUserByStudentId("10205101426").getUser_id()));
        System.out.println(result);
    }

    @Test
    public void queryMatchingRoom(){
       userService userService=userServiceGet();
        roomListData result = new roomListData(userService.queryMatchingRoom());
        System.out.println(result.toString());
    }

    @Test
    public void ReceiveMessage(){
       userService userService=userServiceGet();
        System.out.println(new messageList(userService.queryMessageByRoomId(Long.parseLong("23"))));
    }
    @Test
    public void queryInformationById(){
       userService userService=userServiceGet();
        System.out.println(userService.queryInformationByID(Long.parseLong("1")));
    }


}
